﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OpLinesMasterForm.aspx.cs"
    Inherits="FX.CC.Andon.WebSite.SystemManage.OpLinesMasterForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <div class="mini-splitter" style="width: 100%; height: 100%;">
        <div size="50%" showcollapsebutton="true">
            <div class="mini-toolbar" style="padding: 2px; border-top: 0; border-left: 0; border-right: 0;">
                <table>
                    <tr>
                        <td>
                            登录账号：<input id="aLoginCode" class="mini-textbox" emptytext="请输入登录账号" style="width: 150px;"
                                onenter="onKeyEnter" />
                            <a class="mini-button" iconcls="icon-search" onclick="search()">查 询</a>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            职员姓名：<input id="FullName" class="mini-textbox" emptytext="请输入姓名" style="width: 150px;"
                                onenter="onKeyEnter" />
                            <a class="mini-button" iconcls="icon-reset" onclick="reset()">重 置</a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="mini-toolbar" style="padding: 2px; border-top: 0; border-left: 0; border-right: 0;">
                <a class="mini-button" iconcls="icon-add" onclick="add();" plain="true">添加</a> <a
                    class="mini-button" iconcls="icon-remove" onclick="remove1()" plain="true">删除人员</a>
                <span class="separator"></span><a class="mini-button" onclick="close()" iconcls="icon-close"
                    plain="true">关闭</a>
            </div>
            <div class="mini-fit">
                <div id="grid1" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="UserID"
                    borderstyle="border:0;" sizelist="[5,10,20,50]" pagesize="20" onselectionchanged="onSelectionChanged"
                    selectonload="true">
                    <div property="columns">
                        <div type="indexcolumn" width="15">
                        </div>
                        <div field="LoginCode" width="100" headeralign="center" allowsort="true">
                            登录账号
                        </div>
                        <div field="FullName" width="100" headeralign="center" allowsort="true">
                            职员姓名
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div showcollapsebutton="true">
            <div class="mini-toolbar" style="padding: 2px; border-top: 0; border-left: 0; border-right: 0;">
                <a class="mini-button" iconcls="icon-remove" onclick="remove2()" plain="true">删除产线</a>
            </div>
            <div class="mini-fit">
                <div id="grid2" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="RowID"
                    borderstyle="border:0;" sizelist="[10,20,50,100]" pagesize="20">
                    <div property="columns">
                        <div type="indexcolumn" width="15">
                        </div>
                        <div field="LineCode" width="120" headeralign="center" allowsort="true">
                            产线编号
                        </div>
                        <div field="LineName" width="140" headeralign="center" allowsort="true">
                            产线名称
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <iframe id="exportIFrame" style="display: none;"></iframe>
</body>
<script type="text/javascript">
    mini.parse();
    var grid1 = mini.get("grid1");
    var grid2 = mini.get("grid2");
    grid1.setUrl("../service/SystemManageHandler.ashx?action=GetOpLinesList");
    grid1.load();
    function onSelectionChanged(e) {
        var gridETypeCategory = e.sender;
        var record = gridETypeCategory.getSelected();
        if (record) {
            grid2.setUrl("../Service/SystemManageHandler.ashx?action=GetLineListById");
            grid2.load({ UserID: record.UserID });
        }
        else {
            grid2.clearRows();
        }
    }
    function search() {
        var aLoginCode = mini.get("aLoginCode").getValue();
        var FullName = mini.get("FullName").getValue();
        grid1.load({ aLoginCode: aLoginCode, FullName: FullName });
    }

    function onKeyEnter() {
        search();
    }

    function reset(e) {
        mini.get("aLoginCode").setValue("");
        mini.get("FullName").setValue("");
    }
    function add() {
        mini.open({
            url: "SystemManage/AddOpLinesInfoForm.aspx",
            title: "新增", width: 800, height: 510,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { action: "new" };
                iframe.contentWindow.SetData(data);
            },
            ondestroy: function (action) {
                grid1.reload();
            }
        });
    }
    function ondoubleclick() {
        edit();
    }
    function edit() {
        var row = grid1.getSelected();
        if (row) {
            mini.open({
                url: "SystemManage/OpLinesInfoForm.aspx",
                title: "编辑", width: 460, height: 268,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "edit", UserID: row.UserID };
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    grid1.reload();
                }
            });

        } else {
            mini.alert("请选中一条需要编辑的记录!");
        }
    }
    function remove1() {
        var rows = grid1.getSelected();
        if (rows) {
            mini.confirm("您确定删除:" + rows.FullName + "对应的产线信息？", "确定？",
            function (action) {
                if (action == "ok") {
                    $.ajax({
                        url: "../service/SystemManageHandler.ashx?action=RemoveOpLinesByUserID&UserID=" + rows.UserID,
                        success: function (text) {
                            grid1.reload();
                        },
                        error: function () {
                        }
                    });
                } else {
                    return false;
                }
            });
        } else {
            mini.alert("请选中一条您需要删除的记录!");
        }
    }
    function remove2() {
        var rows = grid2.getSelected();
        if (rows) {
            mini.confirm("您确定删除:" + rows.LineName + "产线信息？", "确定？",
            function (action) {
                if (action == "ok") {
                    $.ajax({
                        url: "../service/SystemManageHandler.ashx?action=RemoveOpLinesByRowID&RowID=" + rows.RowID,
                        success: function (text) {
                            grid2.reload();
                        },
                        error: function () {
                        }
                    });
                } else {
                    return false;
                }
            });
        } else {
            mini.alert("请选中一条您需要删除的记录!");
        }
    }
    function CloseWindow(action) {
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }

    function close() {
        CloseWindow("close");
    }
</script>
</html>
